import 'package:aone_common/common.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:prototype/views/game_category/game_category_controller.dart';
import 'package:prototype/views/game_category/view_type/category_grid_view.dart';
import 'package:prototype/views/game_category/view_type/category_row_view.dart';
import 'package:prototype/views/game_category/widgets/favorite_drawer.dart';
import 'package:prototype/views/game_category/widgets/game_app_bar.dart';
import 'package:prototype/views/game_category/widgets/game_sub_class_selector.dart';
import 'package:prototype/views/game_category/widgets/provider_selector.dart';

import '../../theme/custom_theme.dart';

class GameCategoryView extends StatelessWidget {
  const GameCategoryView({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    Get.put(GameCategoryLogic());
    Get.lazyPut(() => FavoriteLogic());
    final ctrl = Get.put(GameCategoryController());

    return Scaffold(
      key: ctrl.scaffoldKey,
      appBar: const GameAppBar(),
      body: LayoutBuilder(builder: (context, constraints) {
        final Animation<RelativeRect> animation =
            ctrl.getPanelAnimation(constraints);
        return Stack(
          children: [
            const ProviderSelector(),
            PositionedTransition(
              rect: animation,
              child: DecoratedBox(
                decoration: BoxDecoration(
                  color: CustomTheme.colorSchema.backgroundColor,
                ),
                child: Column(
                  children: [
                    const GameSubClassSelector(),
                    Obx(
                      () => Expanded(
                        child: ctrl.isGridView
                            ? const CategoryGridView()
                            : const CategoryRowView(),
                      ),
                    )
                  ],
                ),
              ),
            ),
          ],
        );
      }),
      drawer: const FavoriteDrawer(),
    );
  }
}
